/******************************************************************************
	This file is a part of the Snapshot Bioinformatics Project

	Copyright (C) 2012-2013 Jarom Schow

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
#ifndef GEN_BANK_H
#define GEN_BANK_H

#include "BioDefs.h"

#include <QtCore/QObject>
#include <QtCore/QStringList>

class QFtp;
class QUrl;
class QUrlInfo;

namespace Bio {

class BIO_EXPORT GenBank : public QObject {
	Q_OBJECT
public:
	enum Division { Primate = 0, Rodent, Mammal, Vertebrate, Invertebrate, Plant, Bacterial, Viral, Phage, 
		Synthetic, Unannotated, Patent, Environmental, Constructed, EST, STS, GSS, HTGS, HTC, NumDivisions };
	
	GenBank();
	virtual ~GenBank();

	bool	connectToGenBank();

	int		getReleaseNumber() const;
	qint64	getDivisionSize( Division div ) const;

	int		getNumFiles( Division div ) const;
	QString	getFileName( Division div, int which ) const;
	QUrl	getFileUrl( Division div, int which ) const;
	qint64	getFileSize( Division div, int which ) const;

	static QString	getDivisionDescription( Division div );
	static QString	getDivisionAbbreviation( Division div );
	
private slots:

	void	commandFinished( int id, bool error );
	void	listInfo( const QUrlInfo &info );

private:

	bool	execute( int commandId );

	struct	DivisionData {
		DivisionData();

		qint64			m_totalSize;
		QStringList		m_files;
		QList<qint64>	m_fileSizes;
	};

	int				m_release, m_cmdId;
	bool			m_connected, m_busy, m_hasError;
	QFtp			*m_ftp;
	DivisionData	m_data[NumDivisions];
};

}; // Bio

#endif // GEN_BANK_H